package com.ruoyi.pims.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pims.domain.HealthBodyMetrics;
import com.ruoyi.pims.service.IHealthBodyMetricsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 健康体征监测(体重+身高)Controller
 * 
 * @author ruoyi
 * @date 2025-05-16
 */
@Controller
@RequestMapping("/pims/health_metrics")
public class HealthBodyMetricsController extends BaseController
{
    private String prefix = "pims/health_metrics";

    @Autowired
    private IHealthBodyMetricsService healthBodyMetricsService;

    @RequiresPermissions("pims:health_metrics:view")
    @GetMapping()
    public String health_metrics()
    {
        return prefix + "/health_metrics";
    }

    /**
     * 查询健康体征监测(体重+身高)列表
     */
    @RequiresPermissions("pims:health_metrics:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HealthBodyMetrics healthBodyMetrics)
    {
        startPage();
        List<HealthBodyMetrics> list = healthBodyMetricsService.selectHealthBodyMetricsList(healthBodyMetrics);
        return getDataTable(list);
    }

    /**
     * 导出健康体征监测(体重+身高)列表
     */
    @RequiresPermissions("pims:health_metrics:export")
    @Log(title = "健康体征监测(体重+身高)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(HealthBodyMetrics healthBodyMetrics)
    {
        List<HealthBodyMetrics> list = healthBodyMetricsService.selectHealthBodyMetricsList(healthBodyMetrics);
        ExcelUtil<HealthBodyMetrics> util = new ExcelUtil<HealthBodyMetrics>(HealthBodyMetrics.class);
        return util.exportExcel(list, "健康体征监测(体重+身高)数据");
    }

    /**
     * 新增健康体征监测(体重+身高)
     */
    @RequiresPermissions("pims:health_metrics:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存健康体征监测(体重+身高)
     */
    @RequiresPermissions("pims:health_metrics:add")
    @Log(title = "健康体征监测(体重+身高)", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(HealthBodyMetrics healthBodyMetrics)
    {
        return toAjax(healthBodyMetricsService.insertHealthBodyMetrics(healthBodyMetrics));
    }

    /**
     * 修改健康体征监测(体重+身高)
     */
    @RequiresPermissions("pims:health_metrics:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        HealthBodyMetrics healthBodyMetrics = healthBodyMetricsService.selectHealthBodyMetricsById(id);
        mmap.put("healthBodyMetrics", healthBodyMetrics);
        return prefix + "/edit";
    }

    /**
     * 修改保存健康体征监测(体重+身高)
     */
    @RequiresPermissions("pims:health_metrics:edit")
    @Log(title = "健康体征监测(体重+身高)", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(HealthBodyMetrics healthBodyMetrics)
    {
        return toAjax(healthBodyMetricsService.updateHealthBodyMetrics(healthBodyMetrics));
    }

    /**
     * 删除健康体征监测(体重+身高)
     */
    @RequiresPermissions("pims:health_metrics:remove")
    @Log(title = "健康体征监测(体重+身高)", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(healthBodyMetricsService.deleteHealthBodyMetricsByIds(ids));
    }
}
